<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  
  <title>mysql | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="mysql安装">
<meta property="og:type" content="article">
<meta property="og:title" content="mysql">
<meta property="og:url" content="https://renshengdian.gitee.io/renshengdian/2021/11/01/mysql/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="mysql安装">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://www.runoob.com/wp-content/uploads/2014/03/330405-20160709174318905-664331194.png">
<meta property="og:image" content="http://www.runoob.com/wp-content/uploads/2014/03/20DBD7BA-A653-4AE3-887E-2A16E6EBB2E3.png">
<meta property="og:image" content="http://www.runoob.com/wp-content/uploads/2014/03/330405-20160709174941374-1821908969.png">
<meta property="article:published_time" content="2021-11-01T10:49:19.000Z">
<meta property="article:modified_time" content="2021-11-02T05:43:51.468Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="mysql">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://www.runoob.com/wp-content/uploads/2014/03/330405-20160709174318905-664331194.png">
  
    <link rel="alternate" href="/renshengdian/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="shortcut icon" href="/renshengdian/favicon.png">
  
  
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/typeface-source-code-pro@0.0.71/index.min.css">

  
  
<link rel="stylesheet" href="/renshengdian/css/style.css">

  
    
<link rel="stylesheet" href="/renshengdian/fancybox/jquery.fancybox.min.css">

  
<meta name="generator" content="Hexo 5.4.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/renshengdian/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/renshengdian/">Home</a>
        
          <a class="main-nav-link" href="/renshengdian/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/renshengdian/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="https://renshengdian.gitee.io/renshengdian"></form>
      </div>
    </div>
  </div>
</header>

      <div class="outer">
        <section id="main"><article id="post-mysql" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/renshengdian/2021/11/01/mysql/" class="article-date">
  <time class="dt-published" datetime="2021-11-01T10:49:19.000Z" itemprop="datePublished">2021-11-01</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="p-name article-title" itemprop="headline name">
      mysql
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <h1 id="mysql安装"><a href="#mysql安装" class="headerlink" title="mysql安装"></a>mysql安装</h1><span id="more"></span>

<h1 id="Windows-上安装-MySQL"><a href="#Windows-上安装-MySQL" class="headerlink" title="Windows 上安装 MySQL"></a>Windows 上安装 MySQL</h1><p>Windows 上安装 MySQL 相对来说会较为简单，你需要在 <a target="_blank" rel="noopener" href="http://dev.mysql.com/downloads/mysql/">MySQL 下载</a>中下载 Windows 版本的 MySQL 安装包。</p>
<p>Download Link:&lt; <a target="_blank" rel="noopener" href="https://dev.mysql.com/downloads/mysql/&gt;">https://dev.mysql.com/downloads/mysql/&gt;</a></p>
<p><img src="http://www.runoob.com/wp-content/uploads/2014/03/330405-20160709174318905-664331194.png"></p>
<p><img src="http://www.runoob.com/wp-content/uploads/2014/03/20DBD7BA-A653-4AE3-887E-2A16E6EBB2E3.png"></p>
<p>点击 <strong>Download</strong> 按钮进入下载页面，点击下图中的 <strong>No thanks, just start my download.</strong> 就可立即下载：</p>
<p><img src="http://www.runoob.com/wp-content/uploads/2014/03/330405-20160709174941374-1821908969.png"></p>
<p>下载完后，我们将 zip 包解压到相应的目录这里我将解压后的文件夹放在 <strong>C:\web\mysql-8.0.11</strong> 下。</p>
<p>(一般不选择C盘，选择另外一个磁盘空间比较大的盘符)</p>
<p><strong>接下来我们需要配置下 MySQL 的配置文件</strong></p>
<p>打开刚刚解压的文件夹 <strong>C:\web\mysql-8.0.11</strong> ，里面有一个系统自带的配置文件 <strong>my-default.ini</strong>，复制该文件，并粘贴在同一目录下，设置新的文件为 <strong>my.ini</strong>，编辑 <strong>my.ini</strong> 配置以下基本信息：</p>
<p>如果没有该ini文件，则新建一个，需要注意的是这两个配置：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">basedir </span><br><span class="line">datadir</span><br><span class="line">======================================================</span><br><span class="line">[mysql]</span><br><span class="line"># 设置mysql客户端默认字符集</span><br><span class="line">default-character-set=utf8</span><br><span class="line"> </span><br><span class="line">[mysqld]</span><br><span class="line"># 设置3306端口</span><br><span class="line">port = 3306</span><br><span class="line"># 设置mysql的安装目录</span><br><span class="line">basedir=C:\web\mysql-8.0.11</span><br><span class="line"># 设置mysql数据库的数据的存放目录</span><br><span class="line">datadir=C:\web\sqldata</span><br><span class="line"># 允许最大连接数</span><br><span class="line">max_connections=20</span><br><span class="line"># 服务端使用的字符集默认为8比特编码的latin1字符集</span><br><span class="line">character-set-server=utf8</span><br><span class="line"># 创建新表时将使用的默认存储引擎</span><br><span class="line">default-storage-engine=INNODB======================================================</span><br></pre></td></tr></table></figure>

<p><strong>接下来我们来启动下 MySQL 数据库：</strong></p>
<p>以管理员身份打开 cmd 命令行工具，切换目录：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cd C:\web\mysql-8.0.11\bin</span><br></pre></td></tr></table></figure>

<p>输入以下安装命令：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysqld install</span><br></pre></td></tr></table></figure>

<p>初始化，在 5.7之后 需要初始化 data 目录：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysqld --initialize-insecure </span><br></pre></td></tr></table></figure>

<p>启动输入以下命令即可：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">net start mysql</span><br><span class="line"></span><br><span class="line">（另附：关闭的命令为 net stop mysql ）</span><br></pre></td></tr></table></figure>

<h3 id="详细教程https-blog-csdn-net-bobo553443-article-details-81383194-ops-request-misc-257B-2522request-255Fid-2522-253A-2522163577162716780262553520-2522-252C-2522scm-2522-253A-252220140713-130102334-pc-255Fblog-2522-257D-amp-request-id-163577162716780262553520-amp-biz-id-0-amp-utm-medium-distribute-pc-search-result-none-task-blog-2-blog-first-rank-v2-rank-v29-1-81383194-pc-v2-rank-blog-default-amp-utm-term-mysql-amp-spm-1018-2226-3001-4450"><a href="#详细教程https-blog-csdn-net-bobo553443-article-details-81383194-ops-request-misc-257B-2522request-255Fid-2522-253A-2522163577162716780262553520-2522-252C-2522scm-2522-253A-252220140713-130102334-pc-255Fblog-2522-257D-amp-request-id-163577162716780262553520-amp-biz-id-0-amp-utm-medium-distribute-pc-search-result-none-task-blog-2-blog-first-rank-v2-rank-v29-1-81383194-pc-v2-rank-blog-default-amp-utm-term-mysql-amp-spm-1018-2226-3001-4450" class="headerlink" title="详细教程https://blog.csdn.net/bobo553443/article/details/81383194?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163577162716780262553520%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&amp;request_id=163577162716780262553520&amp;biz_id=0&amp;utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_v2~rank_v29-1-81383194.pc_v2_rank_blog_default&amp;utm_term=mysql&amp;spm=1018.2226.3001.4450"></a>详细教程<a target="_blank" rel="noopener" href="https://blog.csdn.net/bobo553443/article/details/81383194?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163577162716780262553520%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&amp;request_id=163577162716780262553520&amp;biz_id=0&amp;utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_v2~rank_v29-1-81383194.pc_v2_rank_blog_default&amp;utm_term=mysql&amp;spm=1018.2226.3001.4450">https://blog.csdn.net/bobo553443/article/details/81383194?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163577162716780262553520%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&amp;request_id=163577162716780262553520&amp;biz_id=0&amp;utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_v2~rank_v29-1-81383194.pc_v2_rank_blog_default&amp;utm_term=mysql&amp;spm=1018.2226.3001.4450</a></h3>
      
    </div>
    <footer class="article-footer">
      <a data-url="https://renshengdian.gitee.io/renshengdian/2021/11/01/mysql/" data-id="ckwp2cvnk00065cun69r9355f" data-title="mysql" class="article-share-link">Share</a>
      
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/renshengdian/tags/mysql/" rel="tag">mysql</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/renshengdian/2021/11/01/%E9%85%8D%E7%BD%AEjdk%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          jdk
        
      </div>
    </a>
  
  
    <a href="/renshengdian/2021/11/01/tomcat/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">tomcat</div>
    </a>
  
</nav>

  
</article>


</section>
        
          <aside id="sidebar">
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/renshengdian/tags/ide/" rel="tag">ide</a></li><li class="tag-list-item"><a class="tag-list-link" href="/renshengdian/tags/jdk/" rel="tag">jdk</a></li><li class="tag-list-item"><a class="tag-list-link" href="/renshengdian/tags/mysql/" rel="tag">mysql</a></li><li class="tag-list-item"><a class="tag-list-link" href="/renshengdian/tags/tomcat/" rel="tag">tomcat</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/renshengdian/tags/ide/" style="font-size: 10px;">ide</a> <a href="/renshengdian/tags/jdk/" style="font-size: 20px;">jdk</a> <a href="/renshengdian/tags/mysql/" style="font-size: 10px;">mysql</a> <a href="/renshengdian/tags/tomcat/" style="font-size: 10px;">tomcat</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/renshengdian/archives/2021/12/">December 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/renshengdian/archives/2021/11/">November 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/renshengdian/archives/2021/10/">October 2021</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/renshengdian/2021/12/02/%E4%B8%AD%E7%A7%91%E8%BE%BE/">(no title)</a>
          </li>
        
          <li>
            <a href="/renshengdian/2021/11/17/Mybatis/">(no title)</a>
          </li>
        
          <li>
            <a href="/renshengdian/2021/11/05/ide%E7%A4%BE%E5%8C%BA%E7%89%88%E9%80%82%E9%85%8D%E4%B8%8D%E4%BA%86tomcat/">ide社区版适配不了tomcat</a>
          </li>
        
          <li>
            <a href="/renshengdian/2021/11/01/ide/">ide</a>
          </li>
        
          <li>
            <a href="/renshengdian/2021/11/01/jdk/">jdk</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      
      &copy; 2021 John Doe<br>
      Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>

    </div>
    <nav id="mobile-nav">
  
    <a href="/renshengdian/" class="mobile-nav-link">Home</a>
  
    <a href="/renshengdian/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    


<script src="/renshengdian/js/jquery-3.4.1.min.js"></script>



  
<script src="/renshengdian/fancybox/jquery.fancybox.min.js"></script>




<script src="/renshengdian/js/script.js"></script>





  </div>
</body>
</html>